package com.atguigu.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.atguigu.properties.JdbcProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * @Author: liuaojun
 * @CreateTime: 2025-02-06
 * @Description:
 * @Version: 1.0
 */
@Configuration
public class SpringConfig {
    @Autowired
    JdbcProperties jdbcProperties;

    @Bean
    public DataSource getDataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(jdbcProperties.getDriverClassName());
        druidDataSource.setUrl(jdbcProperties.getUrl());
        druidDataSource.setUsername(jdbcProperties.getUsername());
        druidDataSource.setPassword(jdbcProperties.getPassword());
        return druidDataSource;
    }


}
